import type { ManualInspectionItemModel } from './models';

import { requestClient } from '#/api/request';

/**
 * 查询手动点检项数据集合
 * @param planId 点检计划 Id
 * @returns 返回查询结果
 */
export async function getManualInspectionItemListApi(planId: number) {
  return requestClient.get<ManualInspectionItemModel[]>(
    '/mes/equipment/inspection/item/manual/list',
    {
      params: { planId },
    },
  );
}

/**
 * 分页查询手动点检项数据集合
 * @param params 分页查询参数
 * @returns 返回查询结果
 */
export async function getManualInspectionItemPagedListApi(params?: PageParams) {
  return requestClient.get<PaginationResult<ManualInspectionItemModel>>(
    '/mes/equipment/inspection/item/manual/list-page',
    {
      params,
    },
  );
}

/**
 * 创建手动点检项
 * @param data 要创建的手动点检项
 * @returns 返回结果
 */
export async function createManualInspectionItemApi(data: any) {
  return requestClient.post<boolean>(
    '/mes/equipment/inspection/item/manual',
    data,
  );
}

/**
 * 更新手动点检项
 * @param id 手动点检项 Id
 * @param data 要更新的手动点检项
 * @returns 返回结果
 */
export async function updateManualInspectionItemApi(id: number, data: any) {
  return requestClient.put<boolean>(
    `/mes/equipment/inspection/item/manual/${id}`,
    data,
  );
}

/**
 * 删除手动点检项
 * @param id 手动点检项 Id
 * @returns 返回结果
 */
export async function deleteManualInspectionItemApi(id: number) {
  return requestClient.delete<boolean>(
    `/mes/equipment/inspection/item/manual/${id}`,
  );
}
